<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="前端开发规范, 又年">
    <meta name="description" content="前端代码规范本规范是参考凹凸实验室团队和上海公司团队整理的，制定该规范旨在增强团队开发协作、提高代码质量和打造开发基石的编码规范，以下规范是团队基本约定的内容，必须严格遵循。
一、命名规范1. 目录命名
项目文件夹：projectname
">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>前端开发规范 | 又年</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">
    
    <script src="/libs/jquery/jquery.min.js"></script>
    
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>


<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper head-container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">又年</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>

<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">又年</div>
        <div class="logo-desc">
            
            Never really desperate, only the lost of the soul.
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			Contact
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/blinkfox/hexo-theme-matery" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>

        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/blinkfox/hexo-theme-matery" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/18.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <div class="description center-align post-title">
                        前端开发规范
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/Markdown/">
                                <span class="chip bg-color">Markdown</span>
                            </a>
                        
                            <a href="/tags/%E5%89%8D%E7%AB%AF%E8%A7%84%E8%8C%83/">
                                <span class="chip bg-color">前端规范</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/%E5%89%8D%E7%AB%AF/" class="post-category">
                                前端
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2019-11-27
                </div>
                

                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    6.5k
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-clock fa-fw"></i>阅读时长:&nbsp;&nbsp;
                    26 分
                </div>
                
				
                
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="far fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
            
        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <h2 id="前端代码规范"><a href="#前端代码规范" class="headerlink" title="前端代码规范"></a>前端代码规范</h2><p>本规范是参考凹凸实验室团队和上海公司团队整理的，制定该规范旨在增强团队开发协作、提高代码质量和打造开发基石的编码规范，以下规范是团队基本约定的内容，必须严格遵循。</p>
<h2 id="一、命名规范"><a href="#一、命名规范" class="headerlink" title="一、命名规范"></a>一、命名规范</h2><h3 id="1-目录命名"><a href="#1-目录命名" class="headerlink" title="1. 目录命名"></a>1. 目录命名</h3><ul>
<li>项目文件夹：projectname</li>
<li>样式文件夹：css</li>
<li>脚本文件夹：js</li>
<li>样式类图片文件夹：img</li>
</ul>
<h3 id="2-图片命名"><a href="#2-图片命名" class="headerlink" title="2. 图片命名"></a>2. 图片命名</h3><p>图片命名建议以以下顺序命名：</p>
<p><strong>图片业务（可选） +（mod_）图片功能类别（必选）+ 图片模块名称（可选） + 图片精度（可选）</strong></p>
<ul>
<li><p>图片业务：</p>
<ul>
<li>pp_：拍拍</li>
<li>wx_：微信</li>
<li>sq_：手Q</li>
<li>jd_：京东商城</li>
<li>…</li>
</ul>
</li>
<li><p>图片功能类别：</p>
<ul>
<li>mod_：是否公共，可选</li>
<li>icon：模块类固化的图标</li>
<li>logo：LOGO类</li>
<li>spr：单页面各种元素合并集合</li>
<li>btn：按钮</li>
<li>bg：可平铺或者大背景</li>
<li>…</li>
</ul>
</li>
<li><p>图片模块名称：</p>
<ul>
<li>goodslist：商品列表</li>
<li>goodsinfo：商品信息</li>
<li>userava tar：用户头像</li>
<li>…</li>
</ul>
</li>
<li><p>图片精度：</p>
<ul>
<li>普清：@1x</li>
<li>Retina：@2x | @3x</li>
<li>…</li>
</ul>
</li>
</ul>
<p>如下面例子：</p>
<pre><code>公共模块：
wx_mod_btn_goodlist@2x.png
wx_mod_btn_goodlist.png
mod_btn_goodlist.png 

非公共模块：
wx_btn_goodlist@2x.png
wx_btn_goodlist.png
btn_goodlist.png</code></pre><h4 id="交叉业务协作"><a href="#交叉业务协作" class="headerlink" title="交叉业务协作"></a>交叉业务协作</h4><p>业务交叉协作的时候，为了避免图片命名冲突，建议图片名加上业务和模块前辍，如拍拍侧和手Q侧的业务交叉合作时，侧栏导航icon雪碧图命名：</p>
<pre><code>推荐：
pp_icon_mod_sidenav.png

不推荐：
icon_mod_sidenav.png</code></pre><p>处理高清图片的时候，命名应该加上图片相应的精度说明</p>
<pre><code>推荐：
jdc_logo@1x.png
jdc_logo@2x.png

不推荐：
jdc_logo.png
jdc_logo_retina.png</code></pre><h3 id="3-HTML-CSS文件命名"><a href="#3-HTML-CSS文件命名" class="headerlink" title="3. HTML/CSS文件命名"></a>3. HTML/CSS文件命名</h3><p>确保文件命名总是以字母开头而不是数字，且字母一律小写，以中划线连接且不带其他标点符号，如：</p>
<pre><code>&lt;!-- HTML --&gt;
jdc.html
jdc-list.html
jdc-detail.html

&lt;!-- SASS --&gt;
jdc.scss
jdc-list.scss
jdc-detail.scss</code></pre><h3 id="4-ID命名"><a href="#4-ID命名" class="headerlink" title="4. ID命名"></a>4. ID命名</h3><p>id的命名应该尽量精短、明确，必须以<strong>字母开头命名</strong>，多个单词使用<strong>小驼峰</strong> 命名</p>
<h3 id="5-ClassName命名"><a href="#5-ClassName命名" class="headerlink" title="5. ClassName命名"></a>5. ClassName命名</h3><p> ClassName的命名应该尽量精短、明确，必须以<strong>字母开头命名</strong>，且<strong>全部字母为小写</strong>，单词之间<strong>统一使用中划线</strong> “-” 连接 </p>
<h4 id="命名原则"><a href="#命名原则" class="headerlink" title="命名原则"></a>命名原则</h4><p>基于姓氏命名法（继承 + 外来）</p>
<p>祖先模块不能出现中划线，除了是全站公用模块，如 <code>mod-</code> 系列的命名：</p>
<p><strong>推荐：</strong></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>modulename<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>modulename-info<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>modulename-son<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>modulename-son<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        ...
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>

<span class="token comment" spellcheck="true">&lt;!-- 这个是全站公用模块，祖先模块允许直接出现中划线 --></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>mod-info<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>mod-info-son<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>mod-info-son<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
    ...        
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></code></pre>
<p><strong>不推荐：</strong></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>modulename-info<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>modulename-info-son<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>modulename-info-son<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
    ...        
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></code></pre>
<p>在子孙模块数量可预测的情况下，严格继承祖先模块的命名前缀</p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>modulename<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>modulename-cover<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>modulename-info<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></code></pre>
<p>当子孙模块超过4级或以上的时候，可以考虑在祖先模块内具有识辨性的独立缩写作为新的子孙模块</p>
<p><strong>推荐：</strong></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>modulename<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>modulename_cover<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>modulename_info<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>modulename_info_user<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>modulename_info_user_img<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span> <span class="token attr-name">alt</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token comment" spellcheck="true">&lt;!-- 这个时候 miui 为 modulename_info_user_img 首字母缩写--></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>miui_tit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>miui_txt<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
                ...
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>modulename_info_list<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></code></pre>
<h4 id="6-模块命名"><a href="#6-模块命名" class="headerlink" title="6. 模块命名"></a>6. 模块命名</h4><p>全站公共模块：以 <code>mod-</code> 开头</p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>mod-yours<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></code></pre>
<p>业务公共模块：以 <code>业务名-mod-</code> 开头</p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>paipai-mod-yours<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></code></pre>
<h4 id="7-常用命名推荐"><a href="#7-常用命名推荐" class="headerlink" title="7. 常用命名推荐"></a>7. 常用命名推荐</h4><p><strong>注意</strong>：ad、banner、gg、guanggao 等有机会和广告挂勾的字眠不建议直接用来做ClassName，因为有些浏览器插件（Chrome的广告拦截插件等）会直接过滤这些类名，因此</p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>ad<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></code></pre>
<p>这种广告的英文或拼音类名不应该出现</p>
<p>另外，<strong>敏感不和谐字眼</strong>也不应该出现，如：</p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>fuck<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>jer<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>sm<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>gcd<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span> 
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>ass<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span> 
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>KMT<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span> 
...</code></pre>
<table>
<thead>
<tr>
<th align="left">ClassName</th>
<th align="left">含义</th>
</tr>
</thead>
<tbody><tr>
<td align="left">about</td>
<td align="left">关于</td>
</tr>
<tr>
<td align="left">account</td>
<td align="left">账户</td>
</tr>
<tr>
<td align="left">arrow</td>
<td align="left">箭头图标</td>
</tr>
<tr>
<td align="left">article</td>
<td align="left">文章</td>
</tr>
<tr>
<td align="left">aside</td>
<td align="left">边栏</td>
</tr>
<tr>
<td align="left">audio</td>
<td align="left">音频</td>
</tr>
<tr>
<td align="left">avatar</td>
<td align="left">头像</td>
</tr>
<tr>
<td align="left">bg,background</td>
<td align="left">背景</td>
</tr>
<tr>
<td align="left">bar</td>
<td align="left">栏（工具类）</td>
</tr>
<tr>
<td align="left">branding</td>
<td align="left">品牌化</td>
</tr>
<tr>
<td align="left">crumb,breadcrumbs</td>
<td align="left">面包屑</td>
</tr>
<tr>
<td align="left">btn,button</td>
<td align="left">按钮</td>
</tr>
<tr>
<td align="left">caption</td>
<td align="left">标题，说明</td>
</tr>
<tr>
<td align="left">category</td>
<td align="left">分类</td>
</tr>
<tr>
<td align="left">chart</td>
<td align="left">图表</td>
</tr>
<tr>
<td align="left">clearfix</td>
<td align="left">清除浮动</td>
</tr>
<tr>
<td align="left">close</td>
<td align="left">关闭</td>
</tr>
<tr>
<td align="left">col,column</td>
<td align="left">列</td>
</tr>
<tr>
<td align="left">comment</td>
<td align="left">评论</td>
</tr>
<tr>
<td align="left">community</td>
<td align="left">社区</td>
</tr>
<tr>
<td align="left">container</td>
<td align="left">容器</td>
</tr>
<tr>
<td align="left">content</td>
<td align="left">内容</td>
</tr>
<tr>
<td align="left">copyright</td>
<td align="left">版权</td>
</tr>
<tr>
<td align="left">current</td>
<td align="left">当前态，选中态</td>
</tr>
<tr>
<td align="left">default</td>
<td align="left">默认</td>
</tr>
<tr>
<td align="left">description</td>
<td align="left">描述</td>
</tr>
<tr>
<td align="left">details</td>
<td align="left">细节</td>
</tr>
<tr>
<td align="left">disabled</td>
<td align="left">不可用</td>
</tr>
<tr>
<td align="left">entry</td>
<td align="left">文章，博文</td>
</tr>
<tr>
<td align="left">error</td>
<td align="left">错误</td>
</tr>
<tr>
<td align="left">even</td>
<td align="left">偶数，常用于多行列表或表格中</td>
</tr>
<tr>
<td align="left">fail</td>
<td align="left">失败（提示）</td>
</tr>
<tr>
<td align="left">feature</td>
<td align="left">专题</td>
</tr>
<tr>
<td align="left">fewer</td>
<td align="left">收起</td>
</tr>
<tr>
<td align="left">field</td>
<td align="left">用于表单的输入区域</td>
</tr>
<tr>
<td align="left">figure</td>
<td align="left">图</td>
</tr>
<tr>
<td align="left">filter</td>
<td align="left">筛选</td>
</tr>
<tr>
<td align="left">first</td>
<td align="left">第一个，常用于列表中</td>
</tr>
<tr>
<td align="left">footer</td>
<td align="left">页脚</td>
</tr>
<tr>
<td align="left">forum</td>
<td align="left">论坛</td>
</tr>
<tr>
<td align="left">gallery</td>
<td align="left">画廊</td>
</tr>
<tr>
<td align="left">group</td>
<td align="left">模块，清除浮动</td>
</tr>
<tr>
<td align="left">header</td>
<td align="left">页头</td>
</tr>
<tr>
<td align="left">help</td>
<td align="left">帮助</td>
</tr>
<tr>
<td align="left">hide</td>
<td align="left">隐藏</td>
</tr>
<tr>
<td align="left">hightlight</td>
<td align="left">高亮</td>
</tr>
<tr>
<td align="left">home</td>
<td align="left">主页</td>
</tr>
<tr>
<td align="left">icon</td>
<td align="left">图标</td>
</tr>
<tr>
<td align="left">info,information</td>
<td align="left">信息</td>
</tr>
<tr>
<td align="left">last</td>
<td align="left">最后一个，常用于列表中</td>
</tr>
<tr>
<td align="left">links</td>
<td align="left">链接</td>
</tr>
<tr>
<td align="left">login</td>
<td align="left">登录</td>
</tr>
<tr>
<td align="left">logout</td>
<td align="left">退出</td>
</tr>
<tr>
<td align="left">logo</td>
<td align="left">标志</td>
</tr>
<tr>
<td align="left">main</td>
<td align="left">主体</td>
</tr>
<tr>
<td align="left">menu</td>
<td align="left">菜单</td>
</tr>
<tr>
<td align="left">meta</td>
<td align="left">作者、更新时间等信息栏，一般位于标题之下</td>
</tr>
<tr>
<td align="left">module</td>
<td align="left">模块</td>
</tr>
<tr>
<td align="left">more</td>
<td align="left">更多（展开）</td>
</tr>
<tr>
<td align="left">msg,message</td>
<td align="left">消息</td>
</tr>
<tr>
<td align="left">nav,navigation</td>
<td align="left">导航</td>
</tr>
<tr>
<td align="left">next</td>
<td align="left">下一页</td>
</tr>
<tr>
<td align="left">nub</td>
<td align="left">小块</td>
</tr>
<tr>
<td align="left">odd</td>
<td align="left">奇数，常用于多行列表或表格中</td>
</tr>
<tr>
<td align="left">off</td>
<td align="left">鼠标离开</td>
</tr>
<tr>
<td align="left">on</td>
<td align="left">鼠标移过</td>
</tr>
<tr>
<td align="left">output</td>
<td align="left">输出</td>
</tr>
<tr>
<td align="left">pagination</td>
<td align="left">分页</td>
</tr>
<tr>
<td align="left">pop,popup</td>
<td align="left">弹窗</td>
</tr>
<tr>
<td align="left">preview</td>
<td align="left">预览</td>
</tr>
<tr>
<td align="left">previous</td>
<td align="left">上一页</td>
</tr>
<tr>
<td align="left">primary</td>
<td align="left">主要</td>
</tr>
<tr>
<td align="left">progress</td>
<td align="left">进度条</td>
</tr>
<tr>
<td align="left">promotion</td>
<td align="left">促销</td>
</tr>
<tr>
<td align="left">rcommd,recommendations</td>
<td align="left">推荐</td>
</tr>
<tr>
<td align="left">reg,register</td>
<td align="left">注册</td>
</tr>
<tr>
<td align="left">save</td>
<td align="left">保存</td>
</tr>
<tr>
<td align="left">search</td>
<td align="left">搜索</td>
</tr>
<tr>
<td align="left">secondary</td>
<td align="left">次要</td>
</tr>
<tr>
<td align="left">section</td>
<td align="left">区块</td>
</tr>
<tr>
<td align="left">selected</td>
<td align="left">已选</td>
</tr>
<tr>
<td align="left">share</td>
<td align="left">分享</td>
</tr>
<tr>
<td align="left">show</td>
<td align="left">显示</td>
</tr>
<tr>
<td align="left">sidebar</td>
<td align="left">边栏，侧栏</td>
</tr>
<tr>
<td align="left">slide</td>
<td align="left">幻灯片，图片切换</td>
</tr>
<tr>
<td align="left">sort</td>
<td align="left">排序</td>
</tr>
<tr>
<td align="left">sub</td>
<td align="left">次级的，子级的</td>
</tr>
<tr>
<td align="left">submit</td>
<td align="left">提交</td>
</tr>
<tr>
<td align="left">subscribe</td>
<td align="left">订阅</td>
</tr>
<tr>
<td align="left">subtitle</td>
<td align="left">副标题</td>
</tr>
<tr>
<td align="left">success</td>
<td align="left">成功（提示）</td>
</tr>
<tr>
<td align="left">summary</td>
<td align="left">摘要</td>
</tr>
<tr>
<td align="left">tab</td>
<td align="left">标签页</td>
</tr>
<tr>
<td align="left">table</td>
<td align="left">表格</td>
</tr>
<tr>
<td align="left">txt,text</td>
<td align="left">文本</td>
</tr>
<tr>
<td align="left">thumbnail</td>
<td align="left">缩略图</td>
</tr>
<tr>
<td align="left">time</td>
<td align="left">时间</td>
</tr>
<tr>
<td align="left">tips</td>
<td align="left">提示</td>
</tr>
<tr>
<td align="left">title</td>
<td align="left">标题</td>
</tr>
<tr>
<td align="left">video</td>
<td align="left">视频</td>
</tr>
<tr>
<td align="left">wrap</td>
<td align="left">容器，包，一般用于最外层</td>
</tr>
<tr>
<td align="left">wrapper</td>
<td align="left">容器，包，一般用于最外层</td>
</tr>
</tbody></table>
<h2 id="二、HTML规范"><a href="#二、HTML规范" class="headerlink" title="二、HTML规范"></a>二、HTML规范</h2><h3 id="1-代码规范"><a href="#1-代码规范" class="headerlink" title="1. 代码规范"></a>1. 代码规范</h3><h4 id="DOCTYPE-声明"><a href="#DOCTYPE-声明" class="headerlink" title="DOCTYPE 声明"></a>DOCTYPE 声明</h4><p> HTML文件必须加上 DOCTYPE 声明，并统一使用 HTML5 的文档声明： </p>
<pre class=" language-html"><code class="language-html"><span class="token doctype">&lt;!DOCTYPE html></span></code></pre>
<h4 id="页面语言LANG"><a href="#页面语言LANG" class="headerlink" title="页面语言LANG"></a>页面语言LANG</h4><p>推荐使用属性值 <code>cmn-Hans-CN</code>（简体, 中国大陆），但是考虑浏览器和操作系统的兼容性，目前仍然使用 <code>zh-CN</code> 属性值 ：</p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>html</span> <span class="token attr-name">lang</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>zh-CN<span class="token punctuation">"</span></span><span class="token punctuation">></span></span></code></pre>
<h4 id="CHARSET"><a href="#CHARSET" class="headerlink" title="CHARSET"></a>CHARSET</h4><p> 一般情况下统一使用 “UTF-8” 编码 ， 由于历史原因，有些业务可能会使用 “GBK” 编码 。 请尽量统一写成标准的 “UTF-8”，不要写成 “utf-8” 或 “utf8” 或 “UTF8”。 </p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">charset</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>UTF-8<span class="token punctuation">"</span></span><span class="token punctuation">></span></span></code></pre>
<h4 id="元素及标签闭合"><a href="#元素及标签闭合" class="headerlink" title="元素及标签闭合"></a>元素及标签闭合</h4><p>为了能让浏览器更好的解析代码以及能让代码具有更好的可读性，有如下约定：</p>
<ul>
<li>所有具有开始标签和结束标签的元素都要写上起止标签，某些允许省略开始标签或和束标签的元素亦都要写上。</li>
<li>空元素标签都不加 “/” 字符</li>
</ul>
<p><em>推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">></span></span>我是h1标题<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span>我是一段文字，我有始有终，浏览器能正确解析<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>br</span><span class="token punctuation">></span></span></code></pre>
<p><em>不推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">></span></span>我是h1标题<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span>我是一段文字，我有始无终，浏览器亦能正确解析
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>br</span><span class="token punctuation">/></span></span></code></pre>
<h4 id="书写风格"><a href="#书写风格" class="headerlink" title="书写风格"></a>书写风格</h4><h5 id="代码缩进"><a href="#代码缩进" class="headerlink" title="代码缩进"></a>代码缩进</h5><p>缩进量一致并以Tab键为单位，定义Tab为4个字节，使得各编辑器表现一致（各编辑器有相关配置）</p>
<h5 id="HTML代码大小写"><a href="#HTML代码大小写" class="headerlink" title="HTML代码大小写"></a>HTML代码大小写</h5><ul>
<li>HTML标签名、类名、标签属性和大部分属性值统一用小写</li>
</ul>
<p><em>推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>demo<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></code></pre>
<p><em>不推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>DEMO<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>DIV</span> <span class="token attr-name">CLASS</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>DEMO<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>DIV</span><span class="token punctuation">></span></span></code></pre>
<ul>
<li>HTML文本、CDATA、JavaScript、meta标签某些属性等内容可大小写混合 </li>
</ul>
<pre class=" language-html"><code class="language-html"><span class="token comment" spellcheck="true">&lt;!-- 优先使用 IE 最新版本和 Chrome Frame --></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">http-equiv</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>X-UA-Compatible<span class="token punctuation">"</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>IE<span class="token punctuation">=</span>edge,chrome<span class="token punctuation">=</span>1<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span></code></pre>
<h5 id="类型属性"><a href="#类型属性" class="headerlink" title="类型属性"></a>类型属性</h5><p>不需要为 CSS、JS 指定类型属性，HTML5 中默认已包含</p>
<p><em>推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>link</span> <span class="token attr-name">rel</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>stylesheet<span class="token punctuation">"</span></span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span> <span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token script language-javascript"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span></code></pre>
<p><em>不推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>link</span> <span class="token attr-name">rel</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>stylesheet<span class="token punctuation">"</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>text/css<span class="token punctuation">"</span></span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span> <span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>text/javascript<span class="token punctuation">"</span></span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span> <span class="token punctuation">></span></span><span class="token script language-javascript"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span></code></pre>
<h5 id="元素属性"><a href="#元素属性" class="headerlink" title="元素属性"></a>元素属性</h5><ul>
<li>元素属性值使用双引号语法</li>
<li>元素属性值可以写上的都写上</li>
</ul>
<p><em>推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>text<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>radio<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>name<span class="token punctuation">"</span></span> <span class="token attr-name">checked</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>checked<span class="token punctuation">"</span></span> <span class="token punctuation">></span></span></code></pre>
<p><em>不推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span>text</span><span class="token punctuation">></span></span>    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">'</span>text<span class="token punctuation">'</span></span><span class="token punctuation">></span></span>    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>radio<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>name<span class="token punctuation">"</span></span> <span class="token attr-name">checked</span> <span class="token punctuation">></span></span></code></pre>
<h5 id="特殊字符引用"><a href="#特殊字符引用" class="headerlink" title="特殊字符引用"></a>特殊字符引用</h5><p>文本可以和字符引用混合出现。这种方法可以用来转义在文本中不能合法出现的字符。</p>
<p>在 HTML 中不能使用小于号 “&lt;” 和大于号 “&gt;”特殊字符，浏览器会将它们作为标签解析，若要正确显示，在 HTML 源代码中使用字符实体</p>
<p><em>推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>#<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>more<span class="token entity" title="&gt;">&amp;gt;</span><span class="token entity" title="&gt;">&amp;gt;</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>a</span><span class="token punctuation">></span></span></code></pre>
<p><em>不推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>#<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>more>><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>a</span><span class="token punctuation">></span></span></code></pre>
<p><a href="https://blog.csdn.net/sunbocong/article/details/81032758" target="_blank" rel="noopener">了解更多特殊符号</a></p>
<h5 id="纯数字输入框"><a href="#纯数字输入框" class="headerlink" title="纯数字输入框"></a>纯数字输入框</h5><p>使用 <code>type=&quot;tel&quot;</code> 而不是 <code>type=&quot;number&quot;</code></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>tel<span class="token punctuation">"</span></span><span class="token punctuation">></span></span></code></pre>
<h5 id="代码嵌套"><a href="#代码嵌套" class="headerlink" title="代码嵌套"></a>代码嵌套</h5><ul>
<li>元素嵌套规范，每个块状元素独立一行，内联元素可选</li>
</ul>
<p><em>推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>    
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span></code></pre>
<p><em>不推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>    
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span> 
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span></code></pre>
<ul>
<li>段落元素与标题元素只能嵌套内联元素</li>
</ul>
<p><em>推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span></code></pre>
<p><em>不推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span></code></pre>
<h3 id="2-注释规范"><a href="#2-注释规范" class="headerlink" title="2. 注释规范"></a>2. 注释规范</h3><h4 id="单行注释"><a href="#单行注释" class="headerlink" title="单行注释"></a>单行注释</h4><p>一般用于简单的描述，如某些状态描述、属性描述等</p>
<p>注释内容前后各一个空格字符，注释位于要注释代码的上面，单独占一行</p>
<p><em>推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token comment" spellcheck="true">&lt;!-- Comment Text --></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>...<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></code></pre>
<p><em>不推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>...<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span><span class="token comment" spellcheck="true">&lt;!-- Comment Text --></span>    

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span><span class="token comment" spellcheck="true">&lt;!-- Comment Text --></span>
    ...
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></code></pre>
<h4 id="模块注释"><a href="#模块注释" class="headerlink" title="模块注释"></a>模块注释</h4><p>一般用于描述模块的名称以及模块开始与结束的位置</p>
<p>注释内容前后各一个空格字符，<code>表示模块开始，</code> 表示模块结束，模块与模块之间相隔一行</p>
<p><em>推荐写法：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token comment" spellcheck="true">&lt;!-- S Comment Text A --></span>    
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>mod_a<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    ...
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
<span class="token comment" spellcheck="true">&lt;!-- E Comment Text A --></span>

<span class="token comment" spellcheck="true">&lt;!-- S Comment Text B --></span>    
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>mod_b<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    ...
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
<span class="token comment" spellcheck="true">&lt;!-- E Comment Text B --></span></code></pre>
<p><em>不推荐写法：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token comment" spellcheck="true">&lt;!-- S Comment Text A --></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>mod_a<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    ...
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
<span class="token comment" spellcheck="true">&lt;!-- E Comment Text A --></span>
<span class="token comment" spellcheck="true">&lt;!-- S Comment Text B --></span>    
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>mod_b<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    ...
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
<span class="token comment" spellcheck="true">&lt;!-- E Comment Text B --></span></code></pre>
<h4 id="嵌套模块注释"><a href="#嵌套模块注释" class="headerlink" title="嵌套模块注释"></a>嵌套模块注释</h4><p>当模块注释内再出现模块注释的时候，为了突出主要模块，嵌套模块不再使用</p>
<pre class=" language-html"><code class="language-html"><span class="token comment" spellcheck="true">&lt;!-- S Comment Text --></span>
<span class="token comment" spellcheck="true">&lt;!-- E Comment Text --></span></code></pre>
<p>而改用</p>
<pre class=" language-html"><code class="language-html"><span class="token comment" spellcheck="true">&lt;!-- /Comment Text --></span></code></pre>
<p>注释写在模块结尾标签底部，单独一行。</p>
<pre class=" language-html"><code class="language-html"><span class="token comment" spellcheck="true">&lt;!-- S Comment Text A --></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>mod_a<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>mod_b<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
        ...
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
    <span class="token comment" spellcheck="true">&lt;!-- /mod_b --></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>mod_c<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
        ...
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
    <span class="token comment" spellcheck="true">&lt;!-- /mod_c --></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
<span class="token comment" spellcheck="true">&lt;!-- E Comment Text A --></span></code></pre>
<h3 id="3-文件模板"><a href="#3-文件模板" class="headerlink" title="3. 文件模板"></a>3. 文件模板</h3><h4 id="HTML5-标准模板"><a href="#HTML5-标准模板" class="headerlink" title="HTML5 标准模板"></a>HTML5 标准模板</h4><pre class=" language-html"><code class="language-html"><span class="token doctype">&lt;!DOCTYPE html></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>html</span> <span class="token attr-name">lang</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>zh-CN<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>head</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">charset</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>UTF-8<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>title</span><span class="token punctuation">></span></span>HTML5标准模版<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>title</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>head</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>body</span><span class="token punctuation">></span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>body</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>html</span><span class="token punctuation">></span></span></code></pre>
<h4 id="移动端"><a href="#移动端" class="headerlink" title="移动端"></a>移动端</h4><pre class=" language-html"><code class="language-html"><span class="token doctype">&lt;!DOCTYPE html></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>html</span> <span class="token attr-name">lang</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>zh-CN<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>head</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">charset</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>UTF-8<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>viewport<span class="token punctuation">"</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>width<span class="token punctuation">=</span>device-width, initial-scale<span class="token punctuation">=</span>1.0, maximum-scale<span class="token punctuation">=</span>1.0, user-scalable<span class="token punctuation">=</span>no, shrink-to-fit<span class="token punctuation">=</span>no<span class="token punctuation">"</span></span> <span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>format-detection<span class="token punctuation">"</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>telephone<span class="token punctuation">=</span>no<span class="token punctuation">"</span></span> <span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>title</span><span class="token punctuation">></span></span>移动端HTML模版<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>title</span><span class="token punctuation">></span></span>

<span class="token comment" spellcheck="true">&lt;!-- S DNS预解析 --></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>link</span> <span class="token attr-name">rel</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>dns-prefetch<span class="token punctuation">"</span></span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
<span class="token comment" spellcheck="true">&lt;!-- E DNS预解析 --></span> 

<span class="token comment" spellcheck="true">&lt;!-- S 线上样式页面片，开发请直接取消注释引用 --></span>
<span class="token comment" spellcheck="true">&lt;!-- #include virtual="" --></span>
<span class="token comment" spellcheck="true">&lt;!-- E 线上样式页面片 --></span>

<span class="token comment" spellcheck="true">&lt;!-- S 本地调试，根据开发模式选择调试方式，请开发删除 --></span> 
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>link</span> <span class="token attr-name">rel</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>stylesheet<span class="token punctuation">"</span></span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>css/index.css<span class="token punctuation">"</span></span> <span class="token punctuation">></span></span>
<span class="token comment" spellcheck="true">&lt;!-- /本地调试方式 --></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>link</span> <span class="token attr-name">rel</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>stylesheet<span class="token punctuation">"</span></span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>http://srcPath/index.css<span class="token punctuation">"</span></span> <span class="token punctuation">></span></span>
<span class="token comment" spellcheck="true">&lt;!-- /开发机调试方式 --></span>
<span class="token comment" spellcheck="true">&lt;!-- E 本地调试 --></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>head</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>body</span><span class="token punctuation">></span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>body</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>html</span><span class="token punctuation">></span></span></code></pre>
<h4 id="PC端"><a href="#PC端" class="headerlink" title="PC端"></a>PC端</h4><pre class=" language-html"><code class="language-html"><span class="token doctype">&lt;!DOCTYPE html></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>html</span> <span class="token attr-name">lang</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>zh-CN<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>head</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">charset</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>UTF-8<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>keywords<span class="token punctuation">"</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>your keywords<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>description<span class="token punctuation">"</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>your description<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>author<span class="token punctuation">"</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>author,email address<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>robots<span class="token punctuation">"</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>index,follow<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">http-equiv</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>X-UA-Compatible<span class="token punctuation">"</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>IE<span class="token punctuation">=</span>Edge,chrome<span class="token punctuation">=</span>1<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>renderer<span class="token punctuation">"</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>ie-stand<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>title</span><span class="token punctuation">></span></span>PC端HTML模版<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>title</span><span class="token punctuation">></span></span>

<span class="token comment" spellcheck="true">&lt;!-- S DNS预解析 --></span> 
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>link</span> <span class="token attr-name">rel</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>dns-prefetch<span class="token punctuation">"</span></span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
<span class="token comment" spellcheck="true">&lt;!-- E DNS预解析 --></span> 

<span class="token comment" spellcheck="true">&lt;!-- S 线上样式页面片，开发请直接取消注释引用 --></span>
<span class="token comment" spellcheck="true">&lt;!-- #include virtual="" --></span>
<span class="token comment" spellcheck="true">&lt;!-- E 线上样式页面片 --></span>

<span class="token comment" spellcheck="true">&lt;!-- S 本地调试，根据开发模式选择调试方式，请开发删除 --></span> 
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>link</span> <span class="token attr-name">rel</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>stylesheet<span class="token punctuation">"</span></span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>css/index.css<span class="token punctuation">"</span></span> <span class="token punctuation">></span></span>
<span class="token comment" spellcheck="true">&lt;!-- /本地调试方式 --></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>link</span> <span class="token attr-name">rel</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>stylesheet<span class="token punctuation">"</span></span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>http://srcPath/index.css<span class="token punctuation">"</span></span> <span class="token punctuation">></span></span>
<span class="token comment" spellcheck="true">&lt;!-- /开发机调试方式 --></span>
<span class="token comment" spellcheck="true">&lt;!-- E 本地调试 --></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>head</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>body</span><span class="token punctuation">></span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>body</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>html</span><span class="token punctuation">></span></span></code></pre>
<h2 id="三、图片规范"><a href="#三、图片规范" class="headerlink" title="三、图片规范"></a>三、图片规范</h2><h3 id="1-图片格式"><a href="#1-图片格式" class="headerlink" title="1. 图片格式"></a>1. 图片格式</h3><p>常见的图片格式有 GIF、PNG8、PNG24、JPEG、WEBP，根据图片格式的特性和场景需要选取适合的图片格式。</p>
<h4 id="GIF"><a href="#GIF" class="headerlink" title="GIF"></a>GIF</h4><blockquote>
<p>GIF图象是基于颜色列表的（存储的数据是该点的颜色对应于颜色列表的索引值），最多只支持8位（256色）。GIF文件内部分成许多存储块，用来存储多幅图象或者是决定图象表现行为的控制块，用以实现动画和交互式应用。GIF文件还通过LZW压缩算法压缩图象数据来减少图象尺寸</p>
</blockquote>
<h5 id="特性"><a href="#特性" class="headerlink" title="特性"></a>特性</h5><ul>
<li>优秀的压缩算法使其在一定程度上保证图像质量的同时将体积变得很小。</li>
<li>可插入多帧，从而实现动画效果。</li>
<li>可设置透明色以产生对象浮现于背景之上的效果。</li>
<li>由于采用了8位压缩，最多只能处理256种颜色，故不宜应用于真彩色图片。</li>
</ul>
<h4 id="PNG"><a href="#PNG" class="headerlink" title="PNG"></a>PNG</h4><blockquote>
<p>PNG是20世纪90年代中期开始开发的图像文件存储格式，其目的是企图替代GIF和TIFF文件格式，同时增加一些GIF文件格式所不具备的特性。流式网络图形格式(Portable Network Graphic Format，PNG)名称来源于非官方的“PNG’s Not GIF”，是一种位图文件(bitmap file)存储格式，读成“ping”。PNG用来存储灰度图像时，灰度图像的深度可多到16位，存储彩色图像时，彩色图像的深度可多到48位，并且还可存储多到16位的α通道数据。PNG使用从LZ77派生的无损数据压缩算法。</p>
</blockquote>
<h5 id="特性-1"><a href="#特性-1" class="headerlink" title="特性"></a>特性</h5><ul>
<li>支持256色调色板技术，文件体积小。</li>
<li>无损压缩</li>
<li>最高支持48位真彩色图像以及16位灰度图像。</li>
<li>支持Alpha通道的透明/半透明特性。</li>
<li>支持图像亮度的Gamma校准信息。</li>
<li>支持存储附加文本信息，以保留图像名称、作者、版权、创作时间、注释等信息。</li>
<li>渐近显示和流式读写，适合在网络传输中快速显示预览效果后再展示全貌。</li>
<li>使用CRC防止文件出错。</li>
<li>最新的PNG标准允许在一个文件内存储多幅图像。</li>
</ul>
<h4 id="JPEG"><a href="#JPEG" class="headerlink" title="JPEG"></a>JPEG</h4><blockquote>
<p>JPEG是一种针对照片视频而广泛使用的一种有损压缩标准方法。这个名称代表Joint Photographic Experts Group（联合图像专家小组）。此团队创立于公元1986年，1992年发布了JPEG的标准而在1994年获得了ISO 10918-1的认定</p>
</blockquote>
<h5 id="特性-2"><a href="#特性-2" class="headerlink" title="特性"></a>特性</h5><ul>
<li>适用于储存24位元全采影像</li>
<li>采取的压缩方式通常为有损压缩</li>
<li>不支持透明或动画</li>
<li>压缩比越高影像耗损越大，失真越严重</li>
<li>压缩比在10左右肉眼无法分辨出压缩图与原图的差别</li>
</ul>
<h4 id="WEBP"><a href="#WEBP" class="headerlink" title="WEBP"></a>WEBP</h4><blockquote>
<p>WebP，是一种同时提供了有损压缩与无损压缩的图片文件格式，派生自视频编码格式 VP8，是由Google在购买On2 Technologies后发展出来。WebP最初在2010年发布，2011年11月8日，Google开始让WebP支持无损压缩和透明色的功能，而在2012年8月16日的参考实做libwebp 0.2.0中正式支持</p>
</blockquote>
<h5 id="特性-3"><a href="#特性-3" class="headerlink" title="特性"></a>特性</h5><ul>
<li>同时提供有损压缩和无损压缩两种图片文件格式</li>
<li>文件体积小，无损压缩后，比 PNG 文件少了 45％ 的文件大小；有损压缩后，比 JPEG 文件少了 25% - 34% 文件大小</li>
<li>浏览器兼容差，目前只支持客户端 Chrome 和 Opera 浏览器以及安卓原生浏览器(Andriod 4.0+)，<a href="https://developers.google.com/speed/webp/faq#which_web_browsers_natively_support_webp" target="_blank" rel="noopener">WebP兼容性</a></li>
</ul>
<h4 id="团队约定"><a href="#团队约定" class="headerlink" title="团队约定"></a>团队约定</h4><h5 id="内容图"><a href="#内容图" class="headerlink" title="内容图"></a>内容图</h5><p>内容图多以商品图等照片类图片形式存在，颜色较为丰富，文件体积较大</p>
<ul>
<li>优先考虑 JPEG 格式，条件允许的话优先考虑 WebP 格式</li>
<li>尽量不使用PNG格式，PNG8 色位太低，PNG24 压缩率低，文件体积大</li>
</ul>
<h5 id="背景图"><a href="#背景图" class="headerlink" title="背景图"></a>背景图</h5><p>背景图多为图标等颜色比较简单、文件体积不大、起修饰作用的图片</p>
<ul>
<li>PNG 与 GIF 格式，优先考虑使用 PNG 格式,PNG格式允许更多的颜色并提供更好的压缩率</li>
<li>图像颜色比较简单的，如纯色块线条图标，优先考虑使用 PNG8 格式，避免不使用 JPEG 格式</li>
<li>图像颜色丰富而且图片文件不太大的（40KB 以下）或有半透明效果的优先考虑 PNG24 格式</li>
<li>图像颜色丰富而且文件比较大的（40KB - 200KB）优先考虑 JPEG 格式</li>
<li>条件允许的，优先考虑 WebP 代替 PNG 和 JPEG 格式</li>
</ul>
<h3 id="2-图片大小"><a href="#2-图片大小" class="headerlink" title="2. 图片大小"></a>2. 图片大小</h3><p>中国普通家庭的宽带基本能达到8Mbps，实际速率大约为500—900KB/s，全国3G/4G用户占有比超过了50%，为了保证图片能更好地加载展示给用户看，约定：</p>
<p><strong>PC平台单张的图片的大小不应大于 200KB。</strong></p>
<p><strong>移动平台单张的图片的大小不应大于 100KB。</strong></p>
<p><em>（图片的大小约定标准随全国网速的改变而改变）</em></p>
<h3 id="3-图片质量"><a href="#3-图片质量" class="headerlink" title="3. 图片质量"></a>3. 图片质量</h3><ul>
<li>上线的图片都应该经过压缩处理，压缩后的图片不应该出现肉眼可感知的失真区域</li>
<li>60质量的JPEG格式图片与质量大于60的相比，肉眼已看不出明显的区别，因此保存 JPEG 图的时候，质量一般控制在60，若保真度要求高的图片可适量提高到 80，图片大小控制在 200KB 以内</li>
</ul>
<h3 id="4-图片引入"><a href="#4-图片引入" class="headerlink" title="4. 图片引入"></a>4. 图片引入</h3><ul>
<li>测试内容图应该写上表明图片尺寸的占位图，可以用线上占位图生成服务，如：</li>
</ul>
<pre><code>http://placeholder.qiniudn.com/300x200</code></pre><ul>
<li>HTML 中图片引入不需添加 width、height 属性，alt 属性应该写上</li>
</ul>
<p><em>推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span> <span class="token attr-name">alt</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span> <span class="token punctuation">></span></span></code></pre>
<p><em>不推荐：</em></p>
<pre class=" language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span> <span class="token attr-name">width</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span> <span class="token attr-name">height</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span> <span class="token punctuation">></span></span></code></pre>
<ul>
<li>CSS 中图片引入不需要引号</li>
</ul>
<pre class=" language-css"><code class="language-css"><span class="token selector"><span class="token class">.jdc</span> </span><span class="token punctuation">{</span>
    <span class="token property">background-image</span><span class="token punctuation">:</span> <span class="token url">url(icon.png)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre>
<h4 id="CSS-Sprites-VS-Data-URIs"><a href="#CSS-Sprites-VS-Data-URIs" class="headerlink" title="CSS Sprites VS Data URIs"></a>CSS Sprites VS Data URIs</h4><h5 id="CSS-Sprites特点"><a href="#CSS-Sprites特点" class="headerlink" title="CSS Sprites特点"></a>CSS Sprites特点</h5><ul>
<li>减少请求数</li>
<li>加速图片的显示</li>
<li>维护更新成本大</li>
<li>更多的内存消耗，特别是大体积或有过多空白的 Sprites 图</li>
<li>图片渗漏，相邻的不需展示的图片有可能出现在展示元素中，特别是在高清设备移动设备上</li>
</ul>
<h5 id="Data-URIs（base64编码）"><a href="#Data-URIs（base64编码）" class="headerlink" title="Data URIs（base64编码）"></a>Data URIs（base64编码）</h5><ul>
<li>减少请求数</li>
<li>转换文件体积大，大约比原始的二进制大33%</li>
<li>IE6 / IE7 不支持</li>
<li>图片显示相对较慢，需要更多的CPU消耗</li>
</ul>
<h4 id="CSS-Sprites-使用建议"><a href="#CSS-Sprites-使用建议" class="headerlink" title="CSS Sprites 使用建议"></a>CSS Sprites 使用建议</h4><ul>
<li>适合使用频率高更新频率低的小图标</li>
<li>尽量不留太多的空白</li>
<li>体积较大的图片不合并</li>
<li>确保要合并的小图坐标数值和合并后的 Sprites 图尺寸均为偶数</li>
</ul>
<h4 id="Data-URIs（base64编码）使用建议"><a href="#Data-URIs（base64编码）使用建议" class="headerlink" title="Data URIs（base64编码）使用建议"></a>Data URIs（base64编码）使用建议</h4><ul>
<li>适合更新频率高的小图片，如某些具备自定义功能的标题icon等</li>
<li>转换成 Base64 编码的图片应小于 2KB</li>
<li>移动端不使用 Base64 编码</li>
<li>要兼容 IE6/IE7 的不使用</li>
</ul>
<h2 id="四、CSS规范"><a href="#四、CSS规范" class="headerlink" title="四、CSS规范"></a>四、CSS规范</h2><h3 id="1-代码规范-1"><a href="#1-代码规范-1" class="headerlink" title="1. 代码规范"></a>1. 代码规范</h3><h4 id="编码规范"><a href="#编码规范" class="headerlink" title="编码规范"></a>编码规范</h4><ul>
<li>样式文件必须写上 @charset 规则，并且一定要在样式文件的第一行首个字符位置开始写，编码名用 “UTF-8”</li>
<li>字符 @charset “”; 都用小写字母，不能出现转义符，编码名允许大小混写</li>
</ul>
<p><em>推荐：</em></p>
<pre class=" language-css"><code class="language-css"><span class="token atrule"><span class="token rule">@charset</span> <span class="token string">"UTF-8"</span><span class="token punctuation">;</span></span>

<span class="token selector"><span class="token class">.jdc</span></span><span class="token punctuation">{</span><span class="token punctuation">}</span></code></pre>
<h3 id="2-代码风格"><a href="#2-代码风格" class="headerlink" title="2. 代码风格"></a>2. 代码风格</h3><h4 id="代码格式化"><a href="#代码格式化" class="headerlink" title="代码格式化"></a>代码格式化</h4><p>统一使用展开格式书写样式。样式书写一般有两种：一种是紧凑格式 (Compact)</p>
<pre class=" language-css"><code class="language-css"><span class="token selector"><span class="token class">.jdc</span></span><span class="token punctuation">{</span> <span class="token property">display</span><span class="token punctuation">:</span> block<span class="token punctuation">;</span><span class="token property">width</span><span class="token punctuation">:</span> <span class="token number">50</span>px<span class="token punctuation">;</span><span class="token punctuation">}</span></code></pre>
<p>一种是展开格式（Expanded）</p>
<pre class=" language-CSS"><code class="language-CSS">.jdc{
    display: block;
    width: 50px;
}</code></pre>
<h4 id="代码大小写"><a href="#代码大小写" class="headerlink" title="代码大小写"></a>代码大小写</h4><p>样式选择器，属性名，属性值关键字全部使用小写字母书写 </p>
<h4 id="选择器"><a href="#选择器" class="headerlink" title="选择器"></a>选择器</h4><ul>
<li>尽量少用通用选择器 <code>*</code></li>
<li>不使用 ID 选择器</li>
<li>不使用无具体语义定义的标签选择器</li>
</ul>
<pre class=" language-css"><code class="language-css">`<span class="token comment" spellcheck="true">/* 推荐 */</span><span class="token selector"><span class="token class">.jdc</span> </span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token selector"><span class="token class">.jdc</span> li </span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token selector"><span class="token class">.jdc</span> li p</span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token comment" spellcheck="true">/* 不推荐 */</span><span class="token selector">*</span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token selector"><span class="token id">#jdc</span> </span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token selector"><span class="token class">.jdc</span> div</span><span class="token punctuation">{</span><span class="token punctuation">}</span>`</code></pre>
<h4 id="代码易读性"><a href="#代码易读性" class="headerlink" title="代码易读性"></a>代码易读性</h4><ul>
<li><p>左括号与类名之间一个空格，冒号与属性值之间一个空格。</p>
</li>
<li><p>逗号分隔的取值，逗号之后一个空格。</p>
</li>
</ul>
<p><em>推荐：</em></p>
<pre class=" language-css"><code class="language-css"><span class="token selector"><span class="token class">.jdc</span> </span><span class="token punctuation">{</span>    <span class="token property">box-shadow</span><span class="token punctuation">:</span> <span class="token number">1</span>px <span class="token number">1</span>px <span class="token number">1</span>px <span class="token hexcode">#333</span>, <span class="token number">2</span>px <span class="token number">2</span>px <span class="token number">2</span>px <span class="token hexcode">#ccc</span><span class="token punctuation">;</span><span class="token punctuation">}</span></code></pre>
<ul>
<li>为单个css选择器或新申明开启新行。</li>
</ul>
<p><em>推荐：</em></p>
<pre class=" language-css"><code class="language-css"><span class="token selector"><span class="token class">.jdc</span>, 
<span class="token class">.jdc_logo</span>, 
<span class="token class">.jdc_hd</span> </span><span class="token punctuation">{</span>
    <span class="token property">color</span><span class="token punctuation">:</span> <span class="token hexcode">#ff0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token selector"><span class="token class">.nav</span></span><span class="token punctuation">{</span>
    <span class="token property">color</span><span class="token punctuation">:</span> <span class="token hexcode">#fff</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre>
<ul>
<li><p>颜色值 <code>rgb()</code> <code>rgba()</code> <code>hsl()</code> <code>hsla()</code> <code>rect()</code> 中不需有空格，且取值不要带有不必要的 0 。</p>
</li>
<li><p>属性值十六进制数值能用简写的尽量用简写。</p>
</li>
</ul>
<p><em>推荐：</em></p>
<pre class=" language-css"><code class="language-css"><span class="token selector"><span class="token class">.jdc</span> </span><span class="token punctuation">{</span>
    <span class="token property">color</span><span class="token punctuation">:</span> <span class="token hexcode">#fff</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre>
<ul>
<li>不要为 <code>0</code> 指明单位 。</li>
</ul>
<h4 id="属性值引号"><a href="#属性值引号" class="headerlink" title="属性值引号"></a>属性值引号</h4><p>css属性值需要用到引号时，统一使用单引号。</p>
<h4 id="属性书写顺序"><a href="#属性书写顺序" class="headerlink" title="属性书写顺序"></a>属性书写顺序</h4><p>建议遵循以下顺序：</p>
<ol>
<li>布局定位属性：display / position / float / clear / visibility / overflow</li>
<li>自身属性：width / height / margin / padding / border / background</li>
<li>文本属性：color / font / text-decoration / text-align / vertical-align / white- space / break-word</li>
<li>其他属性（CSS3）：content / cursor / border-radius / box-shadow / text-shadow / background:linear-gradient …</li>
</ol>
<h3 id="3-注释规范"><a href="#3-注释规范" class="headerlink" title="3. 注释规范"></a>3. 注释规范</h3><ul>
<li>注释以字符 <code>/*</code> 开始，以字符 <code>*/</code> 结束</li>
<li>注释不能嵌套</li>
</ul>
<h4 id="单行注释-1"><a href="#单行注释-1" class="headerlink" title="单行注释"></a>单行注释</h4><p>注释内容第一个字符和最后一个字符都是一个空格字符，单独占一行，行与行之间相隔一行</p>
<p><em>推荐：</em></p>
<pre class=" language-css"><code class="language-css"><span class="token comment" spellcheck="true">/* Comment Text */</span>
<span class="token selector"><span class="token class">.jdc</span></span><span class="token punctuation">{</span><span class="token punctuation">}</span>

<span class="token comment" spellcheck="true">/* Comment Text */</span>
<span class="token selector"><span class="token class">.jdc</span></span><span class="token punctuation">{</span><span class="token punctuation">}</span></code></pre>
<h4 id="模块注释-1"><a href="#模块注释-1" class="headerlink" title="模块注释"></a>模块注释</h4><p>注释内容第一个字符和最后一个字符都是一个空格字符，<code>/*</code> 与 模块信息描述占一行，多个横线分隔符<code>-</code>与<code>*/</code>占一行，行与行之间相隔两行</p>
<p><em>推荐：</em></p>
<pre class=" language-css"><code class="language-css"><span class="token comment" spellcheck="true">/* Module A
---------------------------------------------------------------- */</span>
<span class="token selector"><span class="token class">.mod_a</span> </span><span class="token punctuation">{</span><span class="token punctuation">}</span>


<span class="token comment" spellcheck="true">/* Module B
---------------------------------------------------------------- */</span>
<span class="token selector"><span class="token class">.mod_b</span> </span><span class="token punctuation">{</span><span class="token punctuation">}</span></code></pre>
<p><em>不推荐：</em></p>
<pre class=" language-css"><code class="language-css"><span class="token comment" spellcheck="true">/* Module A ---------------------------------------------------- */</span>
<span class="token selector"><span class="token class">.mod_a</span> </span><span class="token punctuation">{</span><span class="token punctuation">}</span>
<span class="token comment" spellcheck="true">/* Module B ---------------------------------------------------- */</span>
<span class="token selector"><span class="token class">.mod_b</span> </span><span class="token punctuation">{</span><span class="token punctuation">}</span></code></pre>
<h4 id="文件信息注释"><a href="#文件信息注释" class="headerlink" title="文件信息注释"></a>文件信息注释</h4><p>在样式文件编码声明 <code>@charset</code> 语句下面注明页面名称、作者、创建日期等信息</p>
<pre class=" language-css"><code class="language-css">`<span class="token atrule"><span class="token rule">@charset</span> <span class="token string">"UTF-8"</span><span class="token punctuation">;</span></span>
<span class="token comment" spellcheck="true">/**
* @desc File Info
* @author Author Name
* @date 2019-10-10
*/</span>`</code></pre>
<h3 id="4-重置样式"><a href="#4-重置样式" class="headerlink" title="4. 重置样式"></a>4. 重置样式</h3><h4 id="移动端-1"><a href="#移动端-1" class="headerlink" title="移动端"></a>移动端</h4><pre class=" language-css"><code class="language-css"><span class="token selector">* </span><span class="token punctuation">{</span> <span class="token property">-webkit-tap-highlight-color</span><span class="token punctuation">:</span> transparent<span class="token punctuation">;</span> <span class="token property">outline</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token property">margin</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token property">padding</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token property">vertical-align</span><span class="token punctuation">:</span> baseline<span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, form, fieldset, legend, button, input, textarea, th, td </span><span class="token punctuation">{</span> <span class="token property">margin</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token property">padding</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token property">vertical-align</span><span class="token punctuation">:</span> baseline<span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">img </span><span class="token punctuation">{</span> <span class="token property">border</span><span class="token punctuation">:</span> <span class="token number">0</span> none<span class="token punctuation">;</span> <span class="token property">vertical-align</span><span class="token punctuation">:</span> top<span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">i, em </span><span class="token punctuation">{</span> <span class="token property">font-style</span><span class="token punctuation">:</span> normal<span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">ol, ul </span><span class="token punctuation">{</span> <span class="token property">list-style</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">input, select, button, h1, h2, h3, h4, h5, h6 </span><span class="token punctuation">{</span> <span class="token property">font-size</span><span class="token punctuation">:</span> <span class="token number">100%</span><span class="token punctuation">;</span> <span class="token property">font-family</span><span class="token punctuation">:</span> inherit<span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">table </span><span class="token punctuation">{</span> <span class="token property">border-collapse</span><span class="token punctuation">:</span> collapse<span class="token punctuation">;</span> <span class="token property">border-spacing</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">a </span><span class="token punctuation">{</span> <span class="token property">text-decoration</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span> <span class="token property">color</span><span class="token punctuation">:</span> <span class="token hexcode">#666</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">body </span><span class="token punctuation">{</span> <span class="token property">margin</span><span class="token punctuation">:</span> <span class="token number">0</span> auto<span class="token punctuation">;</span> <span class="token property">min-width</span><span class="token punctuation">:</span> <span class="token number">320</span>px<span class="token punctuation">;</span> <span class="token property">max-width</span><span class="token punctuation">:</span> <span class="token number">640</span>px<span class="token punctuation">;</span> <span class="token property">height</span><span class="token punctuation">:</span> <span class="token number">100%</span><span class="token punctuation">;</span> <span class="token property">font-size</span><span class="token punctuation">:</span> <span class="token number">14</span>px<span class="token punctuation">;</span> <span class="token property">font-family</span><span class="token punctuation">:</span> -apple-system,Helvetica,sans-serif<span class="token punctuation">;</span> <span class="token property">line-height</span><span class="token punctuation">:</span> <span class="token number">1.5</span><span class="token punctuation">;</span> <span class="token property">color</span><span class="token punctuation">:</span> <span class="token hexcode">#666</span><span class="token punctuation">;</span> <span class="token property">-webkit-text-size-adjust</span><span class="token punctuation">:</span> <span class="token number">100%</span> <span class="token important">!important</span><span class="token punctuation">;</span> <span class="token property">text-size-adjust</span><span class="token punctuation">:</span> <span class="token number">100%</span> <span class="token important">!important</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">input<span class="token attribute">[type="text"]</span>, textarea </span><span class="token punctuation">{</span> <span class="token property">-webkit-appearance</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span> <span class="token property">-moz-appearance</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span> <span class="token property">appearance</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span> <span class="token punctuation">}</span></code></pre>
<h4 id="PC端-1"><a href="#PC端-1" class="headerlink" title="PC端"></a>PC端</h4><pre class=" language-css"><code class="language-css"><span class="token selector">html, body, div, h1, h2, h3, h4, h5, h6, p, dl, dt, dd, ol, ul, li, fieldset, form, label, input, legend, table, caption, tbody, tfoot, thead, tr, th, td, textarea, article, aside, audio, canvas, figure, footer, header, mark, menu, nav, section, time, video </span><span class="token punctuation">{</span> <span class="token property">margin</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token property">padding</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">h1, h2, h3, h4, h5, h6 </span><span class="token punctuation">{</span> <span class="token property">font-size</span><span class="token punctuation">:</span> <span class="token number">100%</span><span class="token punctuation">;</span> <span class="token property">font-weight</span><span class="token punctuation">:</span> normal <span class="token punctuation">}</span>
<span class="token selector">article, aside, dialog, figure, footer, header, hgroup, nav, section, blockquote </span><span class="token punctuation">{</span> <span class="token property">display</span><span class="token punctuation">:</span> block<span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">ul, ol </span><span class="token punctuation">{</span> <span class="token property">list-style</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">img </span><span class="token punctuation">{</span> <span class="token property">border</span><span class="token punctuation">:</span> <span class="token number">0</span> none<span class="token punctuation">;</span> <span class="token property">vertical-align</span><span class="token punctuation">:</span> top<span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">blockquote, q </span><span class="token punctuation">{</span> <span class="token property">quotes</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">blockquote<span class="token pseudo-element">:before</span>, blockquote<span class="token pseudo-element">:after</span>, q<span class="token pseudo-element">:before</span>, q<span class="token pseudo-element">:after</span> </span><span class="token punctuation">{</span> <span class="token property">content</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">table </span><span class="token punctuation">{</span> <span class="token property">border-collapse</span><span class="token punctuation">:</span> collapse<span class="token punctuation">;</span> <span class="token property">border-spacing</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">strong, em, i </span><span class="token punctuation">{</span> <span class="token property">font-style</span><span class="token punctuation">:</span> normal<span class="token punctuation">;</span> <span class="token property">font-weight</span><span class="token punctuation">:</span> normal<span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">ins </span><span class="token punctuation">{</span> <span class="token property">text-decoration</span><span class="token punctuation">:</span> underline<span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">del </span><span class="token punctuation">{</span> <span class="token property">text-decoration</span><span class="token punctuation">:</span> line-through<span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">mark </span><span class="token punctuation">{</span> <span class="token property">background</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">input<span class="token pseudo-element">::-ms-clear</span> </span><span class="token punctuation">{</span> <span class="token property">display</span><span class="token punctuation">:</span> none <span class="token important">!important</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">body </span><span class="token punctuation">{</span> <span class="token property">font</span><span class="token punctuation">:</span> <span class="token number">12</span>px/<span class="token number">1.5</span> <span class="token entity" title="\5FAE">\5FAE</span><span class="token entity" title="\8F6F">\8F6F</span><span class="token entity" title="\96C5">\96C5</span><span class="token entity" title="\9ED1">\9ED1</span>, <span class="token entity" title="\5B8B">\5B8B</span><span class="token entity" title="\4F53">\4F53</span>, <span class="token string">"Hiragino Sans GB"</span>, STHeiti, <span class="token string">"WenQuanYi Micro Hei"</span>, <span class="token string">"Droid Sans Fallback"</span>, SimSun, sans-serif<span class="token punctuation">;</span> <span class="token property">background</span><span class="token punctuation">:</span> <span class="token hexcode">#fff</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">a </span><span class="token punctuation">{</span> <span class="token property">text-decoration</span><span class="token punctuation">:</span> none<span class="token punctuation">;</span> <span class="token property">color</span><span class="token punctuation">:</span> <span class="token hexcode">#333</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
<span class="token selector">a<span class="token pseudo-class">:hover</span> </span><span class="token punctuation">{</span> <span class="token property">text-decoration</span><span class="token punctuation">:</span> underline<span class="token punctuation">;</span> <span class="token punctuation">}</span></code></pre>
<h2 id="五、JavaScript-规范"><a href="#五、JavaScript-规范" class="headerlink" title="五、JavaScript 规范"></a>五、JavaScript 规范</h2><h3 id="1-基本准则"><a href="#1-基本准则" class="headerlink" title="1. 基本准则"></a>1. 基本准则</h3><ul>
<li>符合web标准，结构表现行为分离，兼容性优良。页面性能方面，代码要求简洁明了有序， 尽可能的减小服务器负载，保证最快的解析速度。</li>
<li>项目的维护和二次开发可能是直接或间接的团队合作，所以创建易维护的代码是一个项目成功与否的关键，易维护的代码意味着具有如下特性：<ul>
<li>阅读性好：如良好的注释和命名规范，有文档</li>
<li>具有一致性：看起来如同一个人编写</li>
<li>代码的松耦合，高度模块化：将页面内的元素视为一个个模块，相互独立，尽量避免耦合过高的代码，从html,css,js三个层面都要考虑模块化</li>
<li>严格按照规范编写代码</li>
</ul>
</li>
</ul>
<h3 id="2-规范概要"><a href="#2-规范概要" class="headerlink" title="2. 规范概要"></a>2. 规范概要</h3><p>建议使用eslint配置的 standard 模板规范自己代码换行、缩进等，统一代码风格。</p>
<p>1、 程序结构清晰，简单易懂，单个函数的程序行数不得超过100行。</p>
<p>2、 不要随意定义全局变量，尽量使用局部变量。</p>
<p>3、每个源程序文件，都有文件头说明，说明规格见规范。</p>
<p>4、每个函数，都有函数头说明，说明规格见规范。</p>
<p>5、主要变量（结构、联合、类或对象）定义或引用时，注释能反映其含义。</p>
<p>6、常量定义（DEFINE）有相应说明。</p>
<p>7、处理过程的每个阶段都有相关注释说明。</p>
<p>8、在典型算法前都有注释。</p>
<p>9、利用缩进来显示程序的逻辑结构，缩进量一致并以Tab键为单位，定义Tab为4个字节。</p>
<p>10、循环、分支层次不要超过5层。</p>
<p>11、保持注释与代码完全一致，注释可以与语句在同一行，也可以在上行。</p>
<p>12、空行和空白字符也是一种特殊注释。</p>
<p>13、一目了然的语句不加注释。</p>
<p>14、注释的作用范围可以为：定义、引用、条件分支以及一段代码。</p>
<p>15、注释行数（不包括程序头和函数头说明部份）应占总行数的 1/5 到 1/3 。</p>
<p>16、代码结尾处添加分号， eslint 配置的 standard 模板默认不添加分号，添加分号需要在 rules 字段增加配置： </p>
<pre class=" language-json"><code class="language-json">'semi'<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">"error"</span><span class="token punctuation">,</span> <span class="token string">"always"</span><span class="token punctuation">]</span></code></pre>
<p>17、尽量使用es6语法，写出优雅简洁的代码。</p>
<p>18、创建数组和对象时使用字面量方式创建。</p>
<p>19、 除了三目运算，if,else等禁止简写 </p>
<p>20、判断时使用三等号’===’，而不是二等号’==’</p>

            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://ychaoweb.gitee.io" rel="external nofollow noreferrer">alone</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://ychaoweb.gitee.io/2019/11/27/qian-duan-kai-fa-gui-fan/">https://ychaoweb.gitee.io/2019/11/27/qian-duan-kai-fa-gui-fan/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="https://ychaoweb.gitee.io" target="_blank">alone</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/Markdown/">
                                    <span class="chip bg-color">Markdown</span>
                                </a>
                            
                                <a href="/tags/%E5%89%8D%E7%AB%AF%E8%A7%84%E8%8C%83/">
                                    <span class="chip bg-color">前端规范</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>
            
        </div>
    </div>

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="far fa-dot-circle"></i>&nbsp;本篇
            </div>
            <div class="card">
                <a href="/2019/11/27/qian-duan-kai-fa-gui-fan/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/18.jpg" class="responsive-img" alt="前端开发规范">
                        
                        <span class="card-title">前端开发规范</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            本规范是参考凹凸实验室团队和上海公司团队整理的，制定该规范旨在增强团队开发协作、提高代码质量和打造开发基石的编码规范，以下规范是团队基本约定的内容，必须严格遵循。
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2019-11-27
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/%E5%89%8D%E7%AB%AF/" class="post-category">
                                    前端
                                </a>
                            
                            
                        </span>
                    </div>
                </div>

                
                <div class="card-action article-tags">
                    
                    <a href="/tags/Markdown/">
                        <span class="chip bg-color">Markdown</span>
                    </a>
                    
                    <a href="/tags/%E5%89%8D%E7%AB%AF%E8%A7%84%E8%8C%83/">
                        <span class="chip bg-color">前端规范</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2019/11/27/hexo-da-jian-jian-yi-bo-ke-bing-fa-bu-zai-ma-yun-shang/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/20.jpg" class="responsive-img" alt="Hexo搭建简易博客并发布">
                        
                        <span class="card-title">Hexo搭建简易博客并发布</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            概述Hexo是基于node.js的一个博客制作工具。 我们通过markdown编写文章，然后hexo帮我们生成静态的html页面，将生成的html上传到服务器，就是一个简单的博客。
Hexo官网地址
打开命令行，按照官方的步骤复制粘贴
$ 
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2019-11-27
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/%E5%85%B6%E5%AE%83/" class="post-category">
                                    其它
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/hexo/">
                        <span class="chip bg-color">hexo</span>
                    </a>
                    
                    <a href="/tags/Markdown/">
                        <span class="chip bg-color">Markdown</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>

    
<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


<!-- 代码块折行 -->

<style type="text/css">
code[class*="language-"], pre[class*="language-"] { white-space: pre !important; }
</style>

    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            // headingsOffset: -205,
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>



    <footer class="page-footer bg-color">
    <div class="container row center-align">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            <span id="year">年份</span>
            <a href="https://ychaoweb.gitee.io" target="_blank">alone</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <span id="sitetime">载入运行时间...</span>
            <script>
                function siteTime() {
                    window.setTimeout("siteTime()", 1000);
                    var seconds = 1000;
                    var minutes = seconds * 60;
                    var hours = minutes * 60;
                    var days = hours * 24;
                    var years = days * 365;
                    var today = new Date();
                    var startYear = "2019";
                    var startMonth = "11";
                    var startDate = "25";
                    var startHour = "0";
                    var startMinute = "0";
                    var startSecond = "0";
                    var todayYear = today.getFullYear();
                    var todayMonth = today.getMonth() + 1;
                    var todayDate = today.getDate();
                    var todayHour = today.getHours();
                    var todayMinute = today.getMinutes();
                    var todaySecond = today.getSeconds();
                    var t1 = Date.UTC(startYear, startMonth, startDate, startHour, startMinute, startSecond);
                    var t2 = Date.UTC(todayYear, todayMonth, todayDate, todayHour, todayMinute, todaySecond);
                    var diff = t2 - t1;
                    var diffYears = Math.floor(diff / years);
                    var diffDays = Math.floor((diff / days) - diffYears * 365);
                    var diffHours = Math.floor((diff - (diffYears * 365 + diffDays) * days) / hours);
                    var diffMinutes = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours) /
                        minutes);
                    var diffSeconds = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours -
                        diffMinutes * minutes) / seconds);
                    if (startYear == todayYear) {
                        document.getElementById("year").innerHTML = todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffDays + " 天 " + diffHours +
                            " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    } else {
                        document.getElementById("year").innerHTML = startYear + " - " + todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffYears + " 年 " + diffDays +
                            " 天 " + diffHours + " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    }
                }
                setInterval(siteTime, 1000);
            </script>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">














    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
});
</script>
    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    <!-- Global site tag (gtag.js) - Google Analytics -->


    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    

    

    
    <script type="text/javascript" src="/libs/background/ribbon-dynamic.js" async="async"></script>
    
    
    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
